Skip to content

fix: safe opcache_reset#2073

Draft
AlliBalliBaba wants to merge 9 commits intomainfrom
fix/opcache-safe-reset
Draft

fix: safe opcache_reset#2073
AlliBalliBaba wants to merge 9 commits intomainfrom
fix/opcache-safe-reset

Conversation

@AlliBalliBaba
Copy link
Contributor

@AlliBalliBaba AlliBalliBaba commented Dec 14, 2025

Idea to fix #1737

Just a WIP, to test in CI.

@alexandre-daubois
Copy link
Member

Hi @AlliBalliBaba, any news on this side? 🙂
I think I stumbled across the very same issue with #2265

@AlliBalliBaba
Copy link
Contributor Author

I experimented a lot with juggling thread states, but not sure it's possible to make a reset fully safe from our side alone.

There are 2 main race conditions:

  • A thread parses a script without having restarted after a opcache_reset has been triggered.
  • Multiple threads trigger an opcache_reset simultaneously.

The first race condition kind of gets mitigated by the changes in this PR. THe second one would need to somehow be fixed in php-src or requires a hook to reject opcache_resets.

@withinboredom
Copy link
Member

Can we try doing what we do with the environment functions and simply override/replace the existing one:

  1. take a global write lock (read lock taken before executing a php script)
  2. do the real reset
  3. release the lock

@AlliBalliBaba
Copy link
Contributor Author

Yeah I tried that as well. But an opcache_reset can also happen for other reasons, like after calling opcache_invalidate repeatedly because memory is filling up.

But maybe overwriting the user function would still be a good first step 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FrankenPHP crashes with zend_mm_heap corrupted while running some wordpress sites

3 participants